package whr.modules.ask.controller;

import java.util.Arrays;
import java.util.Date;
import java.util.Map;

import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import whr.common.validator.DateUtil;
import whr.modules.ask.entity.ReplyEntity;
import whr.modules.ask.service.ReplyService;
import whr.common.utils.PageUtils;
import whr.common.utils.R;



/**
 * 
 *
 * @author liuli
 * @email 
 * @date 2024-11-01 10:54:10
 */
@RestController
@RequestMapping("ask/reply")
@Slf4j
public class ReplyController {
    @Autowired
    private ReplyService replyService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("ask:reply:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = replyService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{askId}")
    @RequiresPermissions("ask:reply:info")
    public R info(@PathVariable("askId") Long askId){
		ReplyEntity reply = replyService.getbyI(askId);

        return R.ok().put("reply", reply);
    }

    /**
     * 保存(新增请假申请)状态位0
     */
    @RequestMapping("/save")
    @RequiresPermissions("ask:reply:save")
    public R save(@RequestBody ReplyEntity reply) throws Exception {
        log.info("考勤申请{}",reply);
        replyService.saveByUserName(reply);
        return R.ok();
    }

    /**
     * 修改（审核）同意1 不同意0
     */
    @RequestMapping("/update")
    @RequiresPermissions("ask:reply:update")
    public R update(@RequestBody ReplyEntity reply){
		replyService.updateById(reply);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("ask:reply:delete")
    public R delete(@RequestBody Long[] askIds){
		replyService.removeByIds(Arrays.asList(askIds));

        return R.ok();
    }

}
